﻿local time
local _G = getfenv(0)

for _, v in pairs({
    InterfaceOptionsPartyRaidPanelPartyBackground,
    InterfaceOptionsPartyRaidPanelPartyPets,
    InterfaceOptionsCombatPanelTargetOfTarget,
    InterfaceOptionsCombatPanelTOTDropDown,
    InterfaceOptionsCombatPanelEnemyCastBarsOnPortrait,
}) do
    v:SetAlpha(0.35)
    v:Disable()
    v.Enable = v.Disable
end

local coordsElps = 0
local function UpdateCoords(self, el)
	coordsElps = coordsElps + el
	if coordsElps >= .25 then
		coordsElps = 0
		local x, y = GetPlayerMapPosition("player")
		self.text:SetText(x~=0 and y~=0 and format("(%.0f, %.0f)", x * 100, y * 100) or "")
	end
end

local function CreateFont(parentName, font, fontSize, fontStyle, xShadow, yShadow)
	local f = parentName:CreateFontString(nil, "OVERLAY")
	f:SetFont(font, fontSize, fontStyle)
	f:SetShadowOffset(xShadow, yShadow)
	return f
end

local function SetFontString(parent, fontName, fontHeight, fontStyle)
	local fs = parent:CreateFontString(nil, "OVERLAY")
	fs:SetFont(fontName, fontHeight, fontStyle)
	fs:SetJustifyH("LEFT")
	fs:SetShadowColor(0,0,0)
	fs:SetShadowOffset(1.25, -1.25)
	return fs
end

local function menu(self)
	local unit = string.gsub(self.unit, "(.)", string.upper, 1)
	if(_G[unit.."FrameDropDown"]) then
		ToggleDropDownMenu(1, nil, _G[unit.."FrameDropDown"], "cursor")
	elseif(self.unit:match("party")) then
		ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor")
	else
		FriendsDropDown.unit = self.unit
		FriendsDropDown.id = self.id
		FriendsDropDown.initialize = RaidFrameDropDown_Initialize
		ToggleDropDownMenu(1, nil, FriendsDropDown, "cursor")
	end
end

local function NumFormat(i)
	if (i >= 1000000) then
		return ("%.3fK"):format(i / 1e6):gsub("%.", "M ")
	elseif (i >= 100000) then
		return ("%.3f"):format(i / 1e3):gsub("%.", "K ")
	else
		return i
	end
end

local classIcons = {
	["WARRIOR"] = {0, 0.25, 0, 0.25},
	["MAGE"] = {0.25, 0.49609375, 0, 0.25},
	["ROGUE"] = {0.49609375, 0.7421875, 0, 0.25},
	["DRUID"] = {0.7421875, 0.98828125, 0, 0.25},
	["HUNTER"] = {0, 0.25, 0.25, 0.5},
	["SHAMAN"] = {0.25, 0.49609375, 0.25, 0.5},
	["PRIEST"] = {0.49609375, 0.7421875, 0.25, 0.5},
	["WARLOCK"] = {0.7421875, 0.98828125, 0.25, 0.5},
	["PALADIN"] = {0, 0.25, 0.5, 0.75},
	["DEATHKNIGHT"] = {0.25, 0.49609375, 0.5, 0.75},
}

local function UpdateColor(self, unit, func)
	local colorA, colorB
	local _, class = UnitClass(unit)

	for i = 1, 4 do
		if (unit == "party"..i) then
			colorA = oUF.colors.class[class]
		end
	end

	if (unit == "pet" and GetPetHappiness()) then
		colorA = oUF.colors.happiness[GetPetHappiness()]
	elseif (unit == "player" or not UnitIsFriend("player", unit) and UnitIsPlayer(unit) and UnitClass(unit)) or (unit == "targettarget" or unit == "targettargettarget" or unit == "focustarget" or (unit and unit:find("party%dtarget"))) then
		colorA = oUF.colors.class[class]
	else
		colorB = {1, 1, 1}
	end

	if (colorA) then
		self:SetTextColor(colorA[1], colorA[2], colorA[3])
	elseif (colorB) then
		self:SetTextColor(colorB[1], colorB[2], colorB[3])
	end
end

local function OverrideUpdateLevel(self, unit, name)
	local level = UnitLevel(unit)
	local color = GetDifficultyColor(level)

	if (level < 0) then
		self.Level:SetTextColor(1, 0, 0)
	else
		self.Level:SetTextColor(color.r, color.g, color.b)
	end

	if (unit ~= "player") then
		if (UnitClassification(unit) == "elite") then
			self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Elite")
		elseif (UnitClassification(unit) == "rareelite") then
			self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Rare-Elite")
		elseif (UnitClassification(unit) == "rare") then
			self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Rare")
		elseif (UnitClassification(unit) == "worldboss") then
			self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Elite")
		else
			self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame")
		end
	else
		if oUF_Simple.unitframe.player.elite == 1 then
			self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Elite")
		elseif oUF_Simple.unitframe.player.elite == 2 then
			self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Rare-Elite")
		else
			self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame")
		end
	end
end

local function OverrideUpdateName(self, event, unit)
	if (self.unit == unit) then
		if (self.Background) then
			local _, class = UnitClass(unit)
			if (UnitIsDead(unit) or UnitIsGhost(unit) or UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
				self.Background:SetVertexColor(0.5, 0.5, 0.5)
			elseif (UnitIsFriend(unit, "player") and UnitIsPlayer(unit)) then
				self.Background:SetVertexColor(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b)
			elseif not UnitIsFriend(unit, "player") and UnitIsPlayer(unit) then
				self.Background:SetVertexColor(0.9, 0, 0)
			else
				self.Background:SetVertexColor(UnitSelectionColor(unit))
			end
		end

		if (unit == "target" or unit == "player" or unit == "focus") then
			OverrideUpdateLevel(self, unit, name)
		end

		UpdateColor(self.Name, unit, "SetTextColor")
	end
end

local function UpdateDruidPower(self)
	local bar = self.DruidPower
	local num, str = UnitPowerType("player")
	local min = UnitPower("player", (num ~= 0) and 0 or 3)
	local max = UnitPowerMax("player", (num ~= 0) and 0 or 3)

	bar:SetMinMaxValues(0, max)

	if(min ~= max) then
		bar:SetValue(min)
		bar:SetAlpha(1)

		if(num ~= 0) then
			bar:SetStatusBarColor(0, 144/255, 1)
			bar.Text:SetFormattedText("%d - %d%%", min, math.floor(min / max * 100))
		else
			bar:SetStatusBarColor(0.49609375, 0.7421875, 0)
			bar.Text:SetText()
		end
	else
		bar:SetAlpha(0)
		bar.Text:SetText()
	end
end

local function PostUpdateHealth(self, event, unit, bar, min, max)
	if (UnitIsDead(unit) or UnitIsGhost(unit) or not UnitIsConnected(unit)) then
		if unit == "player" then
			bar.value:SetText("0".."/"..NumFormat(max))
		else
			bar.value:SetText((UnitIsDead(unit) and "Dead") or (UnitIsGhost(unit) and "Ghost") or (not UnitIsConnected(unit) and "Offline"))
		end
	elseif (unit == "targettarget" or unit == "targettargettarget" or unit == "focustarget" or (unit and unit:find("partypet%d")) or (unit and unit:find("party%dtarget"))) then
		bar.value:SetText((min/max * 100 < 100 and string.format("%d%%", min/max * 100)) or "")
	else
		bar.value:SetText(NumFormat(min).."/"..NumFormat(max))
	end

	if (UnitIsDead(unit) or (UnitIsGhost(unit)) or not UnitIsConnected(unit)) then
		self.Health:SetStatusBarColor(0.5, 0.5, 0.5)
	else
		self.Health:SetStatusBarColor(0, 1, 0)
	end

	self:UNIT_NAME_UPDATE(event, unit)
end

local function PostUpdatePower(self, event, unit, bar, min, max)
	if (UnitIsDead(unit) or (UnitIsGhost(unit)) or not UnitIsConnected(unit)) then
		if unit == "player" then
			bar:SetValue(0)
			bar.value:SetText("0".."/"..max)
		else
			bar:SetValue(0)
			bar.value:SetText("")
		end
	elseif (min == 0) then
		bar.value:SetText("")
	elseif (not UnitHasMana(unit)) then
		bar.value:SetText(min)
	elseif (min == max) then
		bar.value:SetText(min)
	else
		if (UnitHasMana(unit)) then
		--	if (unit == "player") then
		--		bar.value:SetText(min)
		--	else
				bar.value:SetText(min.."/"..max)
		--	end
		else
			bar.value:SetText(min)
		end
	end
end

local function SetAuraPosition(self)
	local yPos
	if self.Auras.visibleAuras == 0 then
		yPos = 70
	elseif self.Auras.visibleBuffs ~= 0 and self.Auras.visibleDebuffs ~=0 then
		yPos = (math.floor(((self.Auras.visibleAuras) + 5)/5) * (oUF_Simple.unitframe.target.auraSize + self.Auras.spacing)) + 50
	else
		yPos = (math.floor(((self.Auras.visibleAuras) + 4)/5) * (oUF_Simple.unitframe.target.auraSize + self.Auras.spacing)) + 50
	end
	self.Castbar:SetPoint("BOTTOM", self.Power, "BOTTOM", 40, -yPos)
end

local function PostCreateAuraIcon(self, button, icons)
	icons.showDebuffType = true

	button:SetWidth(20)
	button:SetHeight(20)

	button.cd:SetReverse()
	button.cd:ClearAllPoints()
	button.cd:SetPoint("TOPRIGHT", button, "TOPRIGHT", -1, -1)
	button.cd:SetPoint("BOTTOMLEFT", button, "BOTTOMLEFT", 1, 1)

	button.icon:SetTexCoord(0.04, 0.96, 0.04, 0.96)

	button.overlay:SetTexture("Interface\\BUTTONS\\UI-Debuff-Overlays")
	button.overlay:SetTexCoord(0.296875, 0.5703125, 0, 0.515625)
	button.overlay:ClearAllPoints()
	button.overlay:SetPoint("TOPRIGHT", button, "TOPRIGHT", 1, 1)
	button.overlay:SetPoint("BOTTOMLEFT", button, "BOTTOMLEFT", -1, -1)

	button.overlay.Hide = function(self)
		self:SetVertexColor(0.65, 0.65, 0.65)
	end
end

local function PostUpdateAuraIcon(self, icons, unit, icon, index, offset, filter, debuff)
	--if(debuff and UnitIsEnemy("player", unit)) then
		local _, _, _, _, _, duration, _, isPlayer = UnitAura(unit, index, filter)
		if(duration and duration > 0 and not isPlayer) then
			icon.cd:Hide()
		end
	--end
end

local function frameStyle(self, unit)
	self.menu = menu
	self.colors = colors
	self:EnableMouse(true)
	self:SetFrameStrata((unit == "targettarget" or unit == "targettargettarget") and "MEDIUM" or "LOW")
	self:RegisterForClicks("anyup")
	self:SetAttribute("*type2", "menu")
	self:SetScript("OnEnter", UnitFrame_OnEnter)
	self:SetScript("OnLeave", UnitFrame_OnLeave)

	self.PostCreateAuraIcon = PostCreateAuraIcon
	self.PostUpdateAuraIcon = PostUpdateAuraIcon

	self:SetAttribute("initial-height", (unit == "player" or unit == "target" or unit == "focus") and 42 or 30)
	self:SetAttribute("initial-width", (unit == "player" or unit == "target" or unit == "focus") and 175 or 105)

		--	health
	self.Health = CreateFrame("StatusBar", nil, self)
	self.Health:SetHeight((self:GetHeight() * 0.81))
	self.Health:SetStatusBarTexture(oUF_Simple.media.statusbar, "BORDER")
	self.Health:SetHeight(12)
	self.Health:SetWidth(119)
	self.Health.frequentUpdates = true
	self.PostUpdateHealth = PostUpdateHealth

	self.Health.value = CreateFont(self.Health, oUF_Simple.font.main, 12, nil, 1, -1)
	self.Health.value:SetPoint("CENTER", self.Health, 0, 1)

		--	power
	self.Power = CreateFrame("StatusBar", nil, self)
	self.Power:SetStatusBarTexture(oUF_Simple.media.statusbar, "BORDER")
	self.Power:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -1)
	self.Power:SetPoint("TOPRIGHT", self.Health, "BOTTOMRIGHT", 0, -1)
	self.Power.colorPower = true
	self.Power.colorHappiness = true
	self.Power.frequentUpdates = true
	self.PostUpdatePower = PostUpdatePower

	self.Power.value = CreateFont(self.Power, oUF_Simple.font.main, 12, nil, 1, -1)
	self.Power.value:SetPoint("CENTER", self.Power, 0, 1)

	if (unit == "targettarget" or unit == "targettargettarget" or unit == "focustarget" or (unit and unit:find("partypet%d")) or (unit and unit:find("party%dtarget"))) then
		self.Power.value:Hide()
	end

		--	background
	self.bg = self.Power:CreateTexture(nil, "BACKGROUND")
	self.bg:SetTexture(oUF_Simple.media.statusbar)
	self.bg:SetVertexColor(0, 0, 0, 0.35)
	self.bg:SetPoint("TOPRIGHT", self.Health, 0, (unit == "player") and 19 or 0)
	self.bg:SetPoint("BOTTOMLEFT", self.Power)

		--	name
	self.Name = CreateFont(self.Health, oUF_Simple.font.main, 11, nil, 1, -1)
	self.Name:SetJustifyH("CENTER")
	self.Name:SetHeight(10)
	self:Tag(self.Name, "[name]")
	self.UNIT_NAME_UPDATE = OverrideUpdateName

		--	pvpicons
	self.PvP = self.Health:CreateTexture(self:GetName().."PVPIcon", "OVERLAY", self)
	self.PvP:SetHeight(64)

		--	portraits
	if (unit == "player" and oUF_Simple.unitframe.player.TD) or (unit == "target" and oUF_Simple.unitframe.target.TD) then
		self.Portrait = CreateFrame("PlayerModel", nil, self)
		self.Portrait:SetHeight(50)
		self.Portrait:SetWidth(50)
		self.Portrait:SetFrameStrata("BACKGROUND")
	else
		self.Portrait = self:CreateTexture(nil, "BACKGROUND")
		self.Portrait:SetWidth((unit == "player" or unit == "target" or unit == "focus") and 64 or 37)
		self.Portrait:SetHeight((self.Portrait:GetWidth()))
	end

		--	masterlooter
	self.MasterLooter = self.Health:CreateTexture(nil, "OVERLAY")
	self.MasterLooter:SetHeight(16)
	self.MasterLooter:SetWidth(16)

		--	groupleader
	self.Leader = self.Health:CreateTexture(nil, "OVERLAY")
	self.Leader:SetHeight(16)
	self.Leader:SetWidth(16)
		
		--	raidicons
	self.RaidIcon = self.Health:CreateTexture(nil, "OVERLAY")
	self.RaidIcon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcons", "OVERLAY")
	self.RaidIcon:SetHeight(20)
	self.RaidIcon:SetWidth(20)
	self.RaidIcon:SetPoint("CENTER", self.Portrait, "TOP", 0, -1)

		--	texture anchor
	self.f = CreateFrame("Frame", self:GetName().."TextureFrame", self)
	self.f:SetParent(self)

		--	texture
	self.Overlay = self.Health:CreateTexture(nil, "MEDIUM")
	self.Overlay:SetParent(self.f)

		--	player
	if (unit == "player") then
		self.f:SetHeight(100)
		self.f:SetWidth(232)
		self.f:SetPoint("CENTER", self, -20, -7)

		self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame")
		self.Overlay:SetTexCoord(1, 0.09375, 0, 0.78125)
		self.Overlay:SetAllPoints(self.f)

		if (oUF_Simple.show.pvpicons) then
			self.PvPTimer = self.Health:CreateFontString(self:GetName().."PVPTimer", "OVERLAY")
			self.PvPTimer:SetFont(oUF_Simple.font.main, 11)
			self.PvPTimer:SetShadowOffset(1, -1)
			self.PvPTimer:SetPoint("CENTER", self.f, "TOPLEFT", 38, -15)
		end

		if (oUF_Simple.unitframe.player.extbar) then
			self.extbar = self.Health:CreateTexture(self:GetName().."extbar", self)
			if oUF_Simple.unitframe.player.elite == 0 then
				self.extbar:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame")
			else
				self.extbar:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Elite")
			end
			self.extbar:SetTexCoord(0.3984375, 0, 0, 1)
			self.extbar:SetPoint("TOPLEFT", self.f, "TOPLEFT", 225, 0)
			self.extbar:SetHeight(128)
			self.extbar:SetWidth(128)

			self.extbar.bg = self.Health:CreateTexture(nil, "BACKGROUND")
			self.extbar.bg:SetTexture(oUF_Simple.media.statusbar)
			self.extbar.bg:SetVertexColor(0, 0, 0, 0.35)
			self.extbar.bg:SetPoint("TOPRIGHT", self.Health, 93, (unit == "player") and 19)
			self.extbar.bg:SetPoint("BOTTOMRIGHT", self.Power)
			self.extbar.bg:SetWidth(90)

			self.Health.value:SetPoint("CENTER", self.f, 156, 3)
			self.Health.value:SetVertexColor(1, 0.75, 0)
			self.Power.value:SetPoint("CENTER", self.f, 156, -9)
			
			if (oUF_Simple.unitframe.player.coordinate) then
				self.coordinate = CreateFrame("Frame", nil, self)
				--self.coordinate:ClearAllPoints()
				self.coordinate:SetPoint("CENTER", self.f, 156, -21)
				self.coordinate.text = CreateFont(self.Health, oUF_Simple.font.main, 12, "OUTLINE", 0, 0)
				self.coordinate.text:SetJustifyH("CENTER")
				self.coordinate.text:SetPoint("CENTER", self.f, 157, 18)
				self.coordinate.text:SetVertexColor(0, 1, 0)
				self.coordinate:SetScript("OnUpdate", UpdateCoords)
			else
				self.PerHP = CreateFont(self.Health, oUF_Simple.font.main, 12, "OUTLINE", 0, 0)
				self.PerHP:SetJustifyH("CENTER")
				self.PerHP:SetPoint("CENTER", self.f, 157, 18)
				self.PerHP:SetTextColor(0, 1, 0)
				self:Tag(self.PerHP, "[perhp]".."%")
			end
		end

		self.Leader:SetPoint("TOPLEFT", self.f, 45, -10)
		self.MasterLooter:SetPoint("TOPLEFT", self.f, 85, -10)

		self.Level = CreateFont(self.Health, oUF_Simple.font.main, 12, "OUTLINE", 0, 0)
		self.Level:SetPoint("CENTER", self.f, -62, -16)
		self.Level:SetTextColor(1, 0.78, 0)
		self:Tag(self.Level, "[level]")
		self:SetScript("OnUpdate", function(self)
			if UnitAffectingCombat(unit) then
				self.Level:SetAlpha(0)
			else
				self.Level:SetAlpha(1)
			end
		end)

		self.Combat = self.Health:CreateTexture(nil, "OVERLAY")
		self.Combat:SetPoint("CENTER", self.f, -62, -16)
		self.Combat:SetHeight(24)
		self.Combat:SetWidth(24)

		if oUF_Simple.unitframe.player.TD then
			self.Portrait:SetPoint("TOPLEFT", self.f, 50, -20)
		else
			self.Portrait:SetPoint("TOPLEFT", self.f, 42, -12)
		end
		self.Name:SetPoint("CENTER", self.f, 50, 19)
		self.PvP:SetPoint("TOPLEFT", self.f, 18, -20)
		self.Health:SetPoint("TOPLEFT", self.f, 106, -41)

		self.Threat = self.Health:CreateTexture(nil, "BACKGROUND")
		self.Threat:SetTexture("Interface\\CharacterFrame\\UI-Player-Status")
		self.Threat:SetTexCoord(0, 0.74609375, 0, 0.53125)
		self.Threat:SetPoint("TOPLEFT",self.f, 35, -8)
		self.Threat:SetHeight(66)
		self.Threat:SetWidth(190)
		self.Threat:SetBlendMode("ADD")

		self:SetScale(oUF_Simple.unitframe.player.scale)

		local _, class = UnitClass(unit)
		if(class == "DRUID") then
			self.DruidPower = CreateFrame("StatusBar", nil, self)
			self.DruidPower:SetPoint("BOTTOM", self.Power, "TOP", 0, -20)
			self.DruidPower:SetStatusBarTexture(texture)
			self.DruidPower:SetHeight(1)
			self.DruidPower:SetWidth(230)
			self.DruidPower:SetAlpha(0)

			self.DruidPower.Text = self.DruidPower:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
			self.DruidPower.Text:SetPoint("CENTER", self.DruidPower)
			self.DruidPower.Text:SetTextColor(0, 144/255, 1)

			self:RegisterEvent("UNIT_MANA", UpdateDruidPower)
			self:RegisterEvent("UNIT_ENERGY", UpdateDruidPower)
			self:RegisterEvent("PLAYER_LOGIN", UpdateDruidPower)
		end

		if(class == "DEATHKNIGHT") then
			RuneFrame:ClearAllPoints()
			RuneFrame:SetPoint("TOP", self.f,"BOTTOM", 58, 35)
		end
	end

		--	pet
	if (unit == "pet") then
		self.Debuffs = CreateFrame("Frame", nil, self)
		self.Debuffs:SetFrameStrata("BACKGROUND")
		self.Debuffs:SetHeight(20 * 3)
		self.Debuffs:SetWidth(20 * 3)
		self.Debuffs.size = oUF_Simple.unitframe.pet.auraSize
		self.Debuffs.spacing = 4
		self.Debuffs:SetPoint("TOPLEFT", self, "CENTER", -15, -13)
		self.Debuffs.initialAnchor = "TOPLEFT"
		self.Debuffs["growth-y"] = "DOWN"
		self.Debuffs["growth-x"] = "RIGHT"
		self.Debuffs.num = 6 

		self.f:SetHeight(53)
		self.f:SetWidth(128)
		self.f:SetPoint("CENTER", self, 1, 7)

		self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-SmallTargetingFrame")
		self.Overlay:SetPoint("TOPLEFT", self.f, 0, -2)
		self.Overlay:SetHeight(64)
		self.Overlay:SetWidth(128)

		self.Name:SetPoint("BOTTOMLEFT", self.Health, "TOPLEFT", 0, 3)
		self.Name:SetJustifyH("LEFT")
		self.Name:SetWidth(100)
		self.Name:SetHeight(10)

		self.Health:SetHeight(8)
		self.Health:SetWidth(69)
		self.Health:SetPoint("TOPLEFT", self.f, 46, -22)

		self.Portrait:SetPoint("TOPLEFT", self.f, 7, -6)
	--[[
		self.PvP:SetHeight(50)
		self.PvP:SetPoint("CENTER", self, "LEFT", 1, -8)
	]]
		self.Threat = self.Health:CreateTexture(nil, "BACKGROUND")
		self.Threat:SetTexture("Interface\\TargetingFrame\\UI-PartyFrame-Flash")
		self.Threat:SetTexCoord(0, 1, 1, 0)
		self.Threat:SetHeight(64)
		self.Threat:SetWidth(128)
		self.Threat:SetPoint("TOPLEFT", self.f, -4, 11)

		self:SetScale(oUF_Simple.unitframe.pet.scale)
	end

		--	target + focus
	if (unit == "target" or unit == "focus") then
		self.Auras = CreateFrame("Frame", nil, self)
		self.Auras.gap = true
		self.Auras.size = oUF_Simple.unitframe.target.auraSize
		self.Auras:SetHeight(self.Auras.size * 3)
		self.Auras:SetWidth(self.Auras.size * 6)
		self.Auras:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -4, -5)
		self.Auras.initialAnchor = "TOPLEFT"
		self.Auras["growth-x"] = "RIGHT"
		self.Auras["growth-y"] = "DOWN"
		self.Auras.numBuffs = oUF_Simple.unitframe.target.numBuffs
		self.Auras.numDebuffs = oUF_Simple.unitframe.target.numDebuffs
		self.Auras.spacing = 4

		self.f:SetHeight(100)
		self.f:SetWidth(232)
		self.f:SetPoint("CENTER", self, 20, -7)

		self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame")
		self.Overlay:SetTexCoord(0.09375, 1, 0, 0.78125)
		self.Overlay:SetAllPoints(self.f)

		self.Background = self.Health:CreateTexture(self:GetName().."Background", "BACKGROUND")
		self.Background:SetTexture(oUF_Simple.media.statusbar)
		self.Background:SetTexCoord(0.2, 0.8, 0.3, 0.7)
		self.Background:SetHeight(18)
		self.Background:SetPoint("BOTTOMRIGHT", self.Health, "TOPRIGHT")
		self.Background:SetPoint("BOTTOMLEFT", self.Health, "TOPLEFT") 

		self.Leader:SetPoint("TOPRIGHT", self.f, -45, -10)

		self.MasterLooter:SetPoint("TOPRIGHT", self.f, -85, -10)

		self.Level = CreateFont(self.Health, oUF_Simple.font.main, 12, "OUTLINE", 0, 0)
		self.Level:SetPoint("CENTER", self.f, 63.5, -16)
		self.Level:SetTextColor(1, 0.78, 0)
		self:Tag(self.Level, "[level]")

		if oUF_Simple.show.cp ~= 1 and oUF_Simple.show.cft then
			self.CombatFeedbackText = CreateFont(self.Health, oUF_Simple.font.main, 18, "OUTLINE", 0, 0)
			self.CombatFeedbackText:SetPoint("CENTER", self.Portrait)
		end

		if unit == "target" and oUF_Simple.unitframe.target.TD then
			self.Portrait:SetPoint("TOPRIGHT", self.f, -50, -20)
		else
			self.Portrait:SetPoint("TOPRIGHT", self.f, -42, -12)
		end
		self.PvP:SetPoint("TOPRIGHT", self.f, 3, -20)
		self.Health:SetPoint("TOPRIGHT", self.f, -106, -41)

		self.Name:SetPoint("CENTER", self.f, -52, 19)
		self.Name:SetWidth(110)

		self.PerHP = CreateFont(self.Health, oUF_Simple.font.main, 12, "OUTLINE", 0, 0)
		self.PerHP:SetPoint("RIGHT", self.Health, "LEFT", -6, 0)
		self.PerHP:SetTextColor(1, 0.78, 0)
		self:Tag(self.PerHP, "[perhp]".."%")

		if unit == "target" and oUF_Simple.unitframe.target.Creature then
		--	self.Race = CreateFont(self.Health, oUF_Simple.font.main, 12, "OUTLINE", 0, 0)
		--	self.Race:SetPoint("BOTTOMRIGHT", self.Health, "TOPRIGHT", -8, 22)
		--	self.Race:SetTextColor(1, 1, 1)
		--	self:Tag(self.Race, "[race]")

			self.Creature = CreateFont(self.Health, oUF_Simple.font.main, 12, "OUTLINE", 0, 0)
			self.Creature:SetPoint("BOTTOMLEFT", self.Health, "TOPLEFT", 0, 22)
			self.Creature:SetTextColor(1, 1, 1)
			self:Tag(self.Creature, "[creature]")
		end

		self:SetScale(oUF_Simple.unitframe.target.scale)
	end

		--	ComboPoint
	if (unit == "target" and (select(2, UnitClass("Player")) == "ROGUE" or select(2, UnitClass("Player")) == "DRUID")) then
		if oUF_Simple.show.cp == 1 then
			self.CPoints = self:CreateFontString(nil, "OVERLAY", "SubZoneTextFont")
			self.CPoints:SetPoint("CENTER", self.Portrait)
			self.CPoints:SetTextColor(1, 1, 1)
			self.CPoints.unit = "player"
		elseif oUF_Simple.show.cp == 2 then
			self.CPoints = {}
			self.CPoints.unit = "player"
			for i = 1, 5 do
				self.CPoints[i] = CreateFrame("Frame", nil, self)
				self.CPoints[i]:SetHeight(12)
				self.CPoints[i]:SetWidth(12)

				self.CPoints[i].bg = self.CPoints[i]:CreateTexture(nil, "ARTWORK")
				self.CPoints[i].bg:SetParent(self.CPoints[1])
				self.CPoints[i].bg:SetHeight(12)
				self.CPoints[i].bg:SetWidth(12)
				self.CPoints[i].bg:SetAllPoints(self.CPoints[i])
				self.CPoints[i].bg:SetTexture("Interface\\ComboFrame\\ComboPoint")
				self.CPoints[i].bg:SetTexCoord(0, 0.375, 0, 0.75)

				self.CPoints[i].cp = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
				self.CPoints[i].cp:SetParent(self.CPoints[i])
				self.CPoints[i].cp:SetHeight(21)
				self.CPoints[i].cp:SetWidth(7)
				self.CPoints[i].cp:SetTexture("Interface\\ComboFrame\\ComboPoint")
				self.CPoints[i].cp:SetTexCoord(0.375, 0.5625, 0, 1)
				self.CPoints[i].cp:SetPoint("TOPLEFT", self.CPoints[i], 3, 1)
			end
			self.CPoints[1]:SetPoint("TOPRIGHT", self.Portrait, -2,3)
			self.CPoints[2]:SetPoint("TOP", self.CPoints[1], "BOTTOM",8,3)
			self.CPoints[3]:SetPoint("TOP", self.CPoints[2], "BOTTOM",4,1)
			self.CPoints[4]:SetPoint("TOP", self.CPoints[3], "BOTTOM",1,1)
			self.CPoints[5]:SetPoint("TOP", self.CPoints[4], "BOTTOM",-2,1)
		end
	end

	if (unit == "focus") then
		self.t1 = self.Health:CreateTexture(nil, "BACKGROUND")
		self.t1:SetWidth(24)
		self.t1:SetHeight(16)
		self.t1:SetTexture("Interface\\CharacterFrame\\UI-CharacterFrame-GroupIndicator")
		self.t1:SetTexCoord(0.53125, 0.71875, 0, 1)
		self.t1:SetPoint("BOTTOMRIGHT", self, "TOP", 40, 0)
		self.t1:SetAlpha(0.7)

		self.t2 = self.Health:CreateTexture(nil, "BACKGROUND")
		self.t2:SetWidth(38)
		self.t2:SetHeight(16)
		self.t2:SetTexture("Interface\\CharacterFrame\\UI-CharacterFrame-GroupIndicator")
		self.t2:SetPoint("RIGHT", self.t1, "LEFT")
		self.t2:SetTexCoord(0.1875, 0.53125, 0, 1)
		self.t2:SetAlpha(0.7)

		self.t3 = self.Health:CreateTexture(nil, "BACKGROUND")
		self.t3:SetWidth(24)
		self.t3:SetHeight(16)
		self.t3:SetTexture("Interface\\CharacterFrame\\UI-CharacterFrame-GroupIndicator")
		self.t3:SetTexCoord(0, 0.1875, 0, 1)
		self.t3:SetPoint("RIGHT", self.t2, "LEFT")
		self.t3:SetAlpha(0.7)

		self.f1 = self.Health:CreateFontString(nil, "OVERLAY")
		self.f1:SetFont(oUF_Simple.font.main, 12)
		self.f1:SetShadowOffset(1, -1)
		self.f1:SetPoint("CENTER", self.t2, 0, -1)
		self.f1:SetText("Focus")
		self.f1:SetAlpha(0.7)
	end

		--	targetstarget, targetstargetstarget, focusstarget, partypet, partytarget
	if (unit == "targettarget" or unit == "targettargettarget" or unit == "focustarget" or (unit and unit:find("partypet%d")) or (unit and unit:find("party%dtarget"))) then
		self:SetAttribute("initial-height", 20)
		self:SetAttribute("initial-width", 85)

		self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-TargetofTargetFrame")
		self.Overlay:SetTexCoord(0.015625, 0.7265625, 0, 0.703125)
		self.Overlay:SetPoint("CENTER", self, 0, 0)
		self.Overlay:SetHeight(45)
		self.Overlay:SetWidth(93)

		self.Name:SetPoint("TOPLEFT", self, "CENTER", -3, -11)
		self.Name:SetJustifyH("LEFT")
		self.Name:SetWidth(100)

		self.Health:SetHeight(7)
		self.Health:SetWidth(47)
		self.Health:SetPoint("CENTER", self, 22, 4)

		self.Health.value:SetPoint("CENTER", self, "CENTER", 23, 1)

		self.Portrait:SetPoint("LEFT", self, "CENTER", -43, 0)
	end

		--	party
	if (self:GetParent():GetName():match("Party")) then
		self.Debuffs = CreateFrame("Frame", nil, self)
		self.Debuffs:SetFrameStrata("BACKGROUND")
		self.Debuffs:SetHeight(20)
		self.Debuffs:SetWidth(100)
		self.Debuffs.size = oUF_Simple.unitframe.party.auraSize
		self.Debuffs.spacing = 4
		self.Debuffs:SetPoint("LEFT", self, "RIGHT", 10, 20)
		self.Debuffs.initialAnchor = "LEFT"
		self.Debuffs["growth-y"] = "DOWN"
		self.Debuffs["growth-x"] = "RIGHT"
		self.Debuffs.num = 3 

		self.f:SetHeight(53)
		self.f:SetWidth(128)
		self.f:SetPoint("CENTER", self, 1, 2)

		self.Overlay:SetTexture("Interface\\TargetingFrame\\UI-PartyFrame")
		self.Overlay:SetPoint("TOPLEFT", self.f, 0, -2)
		self.Overlay:SetHeight(64)
		self.Overlay:SetWidth(128)

		self.Leader:SetPoint("TOPLEFT", self.f, 2, 0)

		self.MasterLooter:SetPoint("TOPLEFT", self.f, 29, 0)

		self.Name:SetPoint("BOTTOMLEFT", self.Health, "TOPLEFT", 2, 3)
		self.Name:SetJustifyH("LEFT")
		self.Name:SetWidth(100)

		self.Health:SetPoint("TOPLEFT", self.f, 47, -12)
		self.Health:SetHeight(8)
		self.Health:SetWidth(70)

		self.Portrait:SetPoint("TOPLEFT", self.f, 7, -6)

		self.PvP:SetPoint("TOPLEFT", self.f, -9, -10)
		self.PvP:SetHeight(46)
		self.PvP:SetWidth(46)

		self.Threat = self.Health:CreateTexture(nil, "BACKGROUND")
		self.Threat:SetTexture("Interface\\TargetingFrame\\UI-PartyFrame-Flash")
		self.Threat:SetHeight(63)
		self.Threat:SetWidth(128)
		self.Threat:SetPoint("TOPLEFT", self.f, -3, 2)

		self.Level = CreateFont(self.Health, oUF_Simple.font.main, 12, nil, 0, 0)
		self.Level:SetPoint("CENTER", self.f, -60, -16)
		self.Level:SetTextColor(1, 0.78, 0)
		self:Tag(self.Level, "[level]")

		self:SetScale(oUF_Simple.unitframe.party.scale)
	end

		--	set frames movable
	if unit == "player" or unit == "target" or unit == "targettarget" or unit == "focus" then
		if oUF_Simple.show.movable then
			self:SetMovable(true)
			self:RegisterForDrag("LeftButton")

			self:SetScript("OnDragStart", function(self)
				if (IsShiftKeyDown()) then
					if(not InCombatLockdown() and self:IsShown()) then
						self:ClearAllPoints()
						self:StartMoving()
					end
				end
			end)

			self:SetScript("OnDragStop", function(self) 
				self:StopMovingOrSizing()
			end)
		end
	end

		--	mouseover text
	if (unit == "player" and oUF_Simple.unitframe.player.mouseoverText and oUF_Simple.unitframe.player.extbar == false or unit == "pet" and oUF_Simple.unitframe.pet.mouseoverText or unit == "target" and oUF_Simple.unitframe.target.mouseoverText or unit == "focus" and oUF_Simple.unitframe.focus.mouseoverText or (self:GetParent():GetName():match("Party") or (unit and unit:find("partypet%d"))) and oUF_Simple.unitframe.party.mouseoverText) then
		self.Health.value:Hide()
		self.Power.value:Hide()

		self:SetScript("OnEnter", function(self)
			self.Health.value:Show()
			self.Power.value:Show()
			UnitFrame_OnEnter(self)
		end)

		self:SetScript("OnLeave", function(self)
			self.Health.value:Hide()
			self.Power.value:Hide()
			UnitFrame_OnLeave(self)
		end)
	end

	self.Power:SetHeight((self.Health:GetHeight() - 1))

	self.PvP:SetWidth((self.PvP:GetHeight()))

	if (not oUF_Simple.show.pvpicons) then
		self.PvP:Hide()
		self.PvP.Show = function() end
	end

	if (unit == "pet" or self:GetParent():GetName():match("Party") or unit:find("partypet%d")) then
		self.Range = true
		self.inRangeAlpha = 1
		self.outsideRangeAlpha = 0.6
	end

	self.disallowVehicleSwap = true

		--	castbars
		--	target & focus 
	if ((unit == "target" or unit == "focus") and oUF_Simple.castbars.targetfocus.enable) then
		self.Castbar = CreateFrame("StatusBar", nil, self)
		self:SetScript("OnUpdate", SetAuraPosition)
		self.Castbar:SetHeight(13)
		self.Castbar:SetWidth(152)
		self.Castbar:SetStatusBarTexture(oUF_Simple.media.statusbar)
		self.Castbar:SetStatusBarColor(1, 0.7, 0)

		self.CastbarBorder = self:CreateTexture(nil, "OVERLAY")
		self.CastbarBorder:SetParent(self.Castbar)
		self.CastbarBorder:SetTexture(oUF_Simple.media.castbarborder)
		self.CastbarBorder:SetWidth(197)
		self.CastbarBorder:SetHeight(49)
		self.CastbarBorder:ClearAllPoints()
		self.CastbarBorder:SetPoint("TOP", self.Castbar, "TOP", -1, 19)

		self.Castbar.Spark = self.Castbar:CreateTexture(nil, "OVERLAY")
		self.Castbar.Spark:SetHeight(26)
		self.Castbar.Spark:SetBlendMode('ADD')

		self.Castbar.Text = SetFontString(self.Castbar, oUF_Simple.font.main, 10)
		self.Castbar.Text:SetPoint("CENTER", 0, 2)
		self.Castbar.Text:SetTextColor(1, 1, 1)
	--[[
		self.Castbar.Time = SetFontString(self.Castbar, oUF_Simple.font.main, 10)
		self.Castbar.Time:SetPoint("RIGHT", -10, 3)
		self.Castbar.Time:SetTextColor(oUF_Simple.castbars.targetfocus.textcoler[1],oUF_Simple.castbars.targetfocus.textcoler[2],oUF_Simple.castbars.targetfocus.textcoler[3])
		self.Castbar.Time:SetJustifyH("RIGHT")
		self.Castbar.CustomTimeText = OverrideCastbarTime
	]]
		local _, _, _, texture = UnitCastingInfo(unit)
		self.Castbar.Icon = self.Castbar:CreateTexture(nil, "ARTWORK")
		self.Castbar.Icon:SetHeight(16)
		self.Castbar.Icon:SetWidth(16)
		self.Castbar.Icon:SetPoint("LEFT", -22, 1)
		self.Castbar.Icon:SetTexture(texture)
	end

		--	party
	if ((self:GetParent():GetName():match("Party")) and oUF_Simple.castbars.party.enable) then
		self.Castbar = CreateFrame("StatusBar", nil, self)
		self.Castbar:SetPoint("BOTTOM", self.Power, "BOTTOM", -20, -46)
		self.Castbar:SetHeight(10)
		self.Castbar:SetWidth(114)
		self.Castbar:SetStatusBarTexture(oUF_Simple.media.statusbar)
		self.Castbar:SetStatusBarColor(1, 0.7, 0)

		self.Castbar.Spark = self.Castbar:CreateTexture(nil, "OVERLAY")
		self.Castbar.Spark:SetHeight(20)
		self.Castbar.Spark:SetBlendMode('ADD')

		self.CastbarBorder = self:CreateTexture(nil, "OVERLAY")
		self.CastbarBorder:SetParent(self.Castbar)
		self.CastbarBorder:SetTexture(oUF_Simple.media.castbarborder)
		self.CastbarBorder:SetWidth(148)
		self.CastbarBorder:SetHeight(37)
		self.CastbarBorder:ClearAllPoints()
		self.CastbarBorder:SetPoint("TOP", self.Castbar, "TOP", -1, 14)

		self.Castbar.Text = SetFontString(self.Castbar, oUF_Simple.font.main, 8)
		self.Castbar.Text:SetPoint("CENTER", 0, 1)
		self.Castbar.Text:SetTextColor(1, 1, 1)
	end

		--	classicon
		--	target
	if (unit=="target" and oUF_Simple.show.classicon) then
		TargetClassIcon = CreateFrame("Frame", nil, self)
		TargetClassIcon:SetWidth(20)
		TargetClassIcon:SetHeight(20)
		TargetClassIcon:ClearAllPoints()
		TargetClassIcon:SetPoint("TOPLEFT", Target, "TOPLEFT", 110, 15)

		TargetClassIcon.Tex = TargetClassIcon:CreateTexture(nil,"ARTWORK")
		TargetClassIcon.Tex:SetTexture("Interface\\WorldStateFrame\\Icons-Classes")
		TargetClassIcon.Tex:SetAllPoints(TargetClassIcon)
		TargetClassIcon:RegisterEvent("PLAYER_TARGET_CHANGED")
		TargetClassIcon:SetScript("OnEvent", function(self)
			local targetclass = select(2, UnitClass(unit))
			if targetclass then
				--local targetclass = string.upper(targetclass)
				local class = classIcons[targetclass]
				TargetClassIcon.Tex:SetTexCoord(class[1], class[2], class[3], class[4])
				if UnitIsPlayer(unit) then
					TargetClassIcon:SetAlpha(1)
				else
					TargetClassIcon:SetAlpha(0)
				end
			end
		end)

		TargetClassIconOverlay = TargetClassIcon:CreateTexture(nil, "OVERLAY")
		TargetClassIconOverlay:SetPoint("TOPLEFT", Target, "TOPLEFT", 105, 20)
		TargetClassIconOverlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
		TargetClassIconOverlay:SetWidth(52)
		TargetClassIconOverlay:SetHeight(52)
		TargetClassIconOverlay:SetBlendMode("BLEND")
	end

	return self
end

oUF:RegisterStyle("Simple", frameStyle)
oUF:SetActiveStyle("Simple")

local player = oUF:Spawn("player", "Player")
player:SetPoint(oUF_Simple.unitframe.player.position[1], oUF_Simple.unitframe.player.position[2], oUF_Simple.unitframe.player.position[3], oUF_Simple.unitframe.player.position[4], oUF_Simple.unitframe.player.position[5])

local pet = oUF:Spawn("pet", "PlayerPet")
pet:SetPoint(oUF_Simple.unitframe.pet.position[1], Player, oUF_Simple.unitframe.pet.position[3], oUF_Simple.unitframe.pet.position[4], oUF_Simple.unitframe.pet.position[5])

local target = oUF:Spawn("target", "Target")
if (oUF_Simple.unitframe.player.extbar) then
target:SetPoint(oUF_Simple.unitframe.target.position[1], oUF_Simple.unitframe.target.position[2], oUF_Simple.unitframe.target.position[3], oUF_Simple.unitframe.target.position[4] + 90, oUF_Simple.unitframe.target.position[5])
else
target:SetPoint(oUF_Simple.unitframe.target.position[1], oUF_Simple.unitframe.target.position[2], oUF_Simple.unitframe.target.position[3], oUF_Simple.unitframe.target.position[4], oUF_Simple.unitframe.target.position[5])
end

local tot = oUF:Spawn("targettarget", "TargetsTarget")
tot:SetPoint(oUF_Simple.unitframe.targetstarget.position[1], Target, oUF_Simple.unitframe.targetstarget.position[3], oUF_Simple.unitframe.targetstarget.position[4], oUF_Simple.unitframe.targetstarget.position[5])
tot:SetScale(oUF_Simple.unitframe.targetstarget.scale)

local totot = oUF:Spawn("targettargettarget", "TargetsTargetsTarget")
totot:SetPoint(oUF_Simple.unitframe.targetstargetstarget.position[1], TargetsTarget, oUF_Simple.unitframe.targetstargetstarget.position[3], oUF_Simple.unitframe.targetstargetstarget.position[4], oUF_Simple.unitframe.targetstargetstarget.position[5])
totot:SetScale(oUF_Simple.unitframe.targetstargetstarget.scale)

local focus = oUF:Spawn("focus", "Focus")
focus:SetPoint("LEFT", UIParent, 45, -50.35)

local tofocus = oUF:Spawn("focustarget", "FocussTarget")
tofocus:SetPoint(oUF_Simple.unitframe.focustarget.position[1], Focus, oUF_Simple.unitframe.focustarget.position[3], oUF_Simple.unitframe.focustarget.position[4], oUF_Simple.unitframe.focustarget.position[5])
tofocus:SetScale(oUF_Simple.unitframe.focustarget.scale)

local party = oUF:Spawn("header", "Party")
party:SetPoint(oUF_Simple.unitframe.party.position[1], oUF_Simple.unitframe.party.position[2], oUF_Simple.unitframe.party.position[3], oUF_Simple.unitframe.party.position[4], oUF_Simple.unitframe.party.position[5])
party:SetManyAttributes(
	"showParty", true, "yOffset", -50
)
if (oUF_Simple.show.party) then
	party:Show()
end

local partypet = {}
partypet[1] = oUF:Spawn("partypet1", "PartyPet1")
partypet[1]:SetPoint("TOPRIGHT", party, "TOPRIGHT", -15, -35)
partypet[1]:SetScale(0.7)
for i =2, 4 do
	partypet[i] = oUF:Spawn("partypet"..i, "PartyPet"..i)
	partypet[i]:SetPoint("TOP", partypet[i-1], "BOTTOM", 0, -94)
	partypet[i]:SetScale(0.7)
end

local partytarget = {}
partytarget[1] = oUF:Spawn("party1target", "Party1target")
partytarget[1]:SetPoint("TOPLEFT", party, "TOPRIGHT", 15, -20)
partytarget[1]:SetScale(0.7)
for i =2, 4 do
	partytarget[i] = oUF:Spawn("party"..i.."target", "Party"..i.."target")
	partytarget[i]:SetPoint("TOP", partytarget[i-1], "BOTTOM", 0, -94)
	partytarget[i]:SetScale(0.7)
end

local event = CreateFrame("Frame", nil, Player)

local inLeft = event:CreateTexture(nil, "BACKGROUND")
inLeft:SetWidth(24)
inLeft:SetHeight(16)
inLeft:SetTexture("Interface\\CharacterFrame\\UI-CharacterFrame-GroupIndicator")
inLeft:SetTexCoord(0, 0.1875, 0, 1)
inLeft:SetPoint("BOTTOMLEFT", Player, "TOP", -40, 0)

local inCenter = event:CreateTexture(nil, "BACKGROUND")
inCenter:SetWidth(38)
inCenter:SetHeight(16)
inCenter:SetTexture("Interface\\CharacterFrame\\UI-CharacterFrame-GroupIndicator")
inCenter:SetPoint("LEFT", inLeft, "RIGHT")
inCenter:SetTexCoord(0.1875, 0.53125, 0, 1)

local inRight = event:CreateTexture(nil, "BACKGROUND")
inRight:SetWidth(24)
inRight:SetHeight(16)
inRight:SetTexture("Interface\\CharacterFrame\\UI-CharacterFrame-GroupIndicator")
inRight:SetTexCoord(0.53125, 0.71875, 0, 1)
inRight:SetPoint("LEFT", inCenter, "RIGHT")

local inText = event:CreateFontString(nil, "OVERLAY")
inText:SetFont(oUF_Simple.font.main, 12)
inText:SetShadowOffset(1, -1)
inText:SetPoint("CENTER", inCenter, 0, -1)
inText:SetAlpha(0.6)

event:SetScript("OnEvent", function(self)
	local name, rank, subgroup
	local numRaidMembers = GetNumRaidMembers()

	inCenter:SetAlpha(0)
	inLeft:SetAlpha(0)
	inRight:SetAlpha(0)
	inText:SetText("")

	if (numRaidMembers == 0) then
		inCenter:SetAlpha(0)
		inLeft:SetAlpha(0)
		inRight:SetAlpha(0)
		inText:SetText("")
		return
	end

	for i = 1, MAX_RAID_MEMBERS do
		if (i <= numRaidMembers) then
			name, rank, subgroup = GetRaidRosterInfo(i)
			if (name == UnitName("player")) then
				inText:SetText(GROUP.." "..subgroup)
				inCenter:SetWidth(inText:GetWidth())
				inCenter:SetAlpha(0.7)
				inLeft:SetAlpha(0.7)
				inRight:SetAlpha(0.7)
			end
		end
	end

	if (HIDE_PARTY_INTERFACE == "1") then
		party:Hide()
	end
end)

if (oUF_Simple.show.pvpicons) then
	event:SetScript("OnUpdate", function(self, elapsed)
		if (IsPVPTimerRunning()) then
			time = GetPVPTimer()
		else
			time = nil
		end

		if (time) then
			time = time - elapsed * 1000
			local timeLeft = time
			if (timeLeft < 0) then
				PlayerPVPTimer:SetText("")
			end
			PlayerPVPTimer:SetFormattedText(SecondsToTimeAbbrev(floor(timeLeft/1000)))
		else
			PlayerPVPTimer:SetText("")
		end
	end)
end

event:RegisterEvent("PLAYER_LOGIN")
event:RegisterEvent("CVAR_UPDATE")
event:RegisterEvent("RAID_ROSTER_UPDATE")
event:RegisterEvent("PARTY_LEADER_CHANGED")
event:RegisterEvent("PARTY_MEMBER_CHANGED")